//
//  MyOrderViewController.m
//  1gene
//
//  Created by 1jiyin on 16/5/6.
//  Copyright © 2016年 1jiyin. All rights reserved.
//

#import "MyOrderViewController.h"
#import "UILabel+StringFrame.h"
#import "ProductNextStepViewController.h"
#import "UIImageView+AFNetworking.h"
#import "AFNetworking.h"

@interface MyOrderViewController ()<UITextFieldDelegate>

@property(nonatomic,assign)NSInteger productNumber;

@property(nonatomic,copy)UILabel *productNumberLab;

@property(nonatomic,copy)UIImageView *couponImageView;

@property(nonatomic,copy)UILabel *l1;

@property(nonatomic,copy)UILabel *l2;

@property(nonatomic,copy)UILabel *l3;

@property(nonatomic,copy)UILabel *l4;

@property(nonatomic,copy)UIView *myCustomView;

@property(nonatomic,copy)UILabel *tishiLab;

@property(nonatomic,copy)UITextField *myText3;

@property(nonatomic,copy)UIView *navigationBarView;

@property(nonatomic,copy)UIView *myCustomSubView;

@property(nonatomic,copy)NSMutableArray *cashCouponArray;

@property(nonatomic,copy)NSMutableArray *couponArray;

@property(nonatomic,copy)UIScrollView *scroll1;

@property(nonatomic,copy)UIScrollView *scroll2;

@property(nonatomic,copy)UIScrollView *myScrollView;

@property(nonatomic,copy)UILabel *quanLab1;

@property(nonatomic,copy)UILabel *dikouLab;

@property(nonatomic,assign)CGFloat price;

@property(nonatomic,assign)CGFloat allMoney;

@property(nonatomic,assign)CGFloat couponMoney;

@property(nonatomic,assign)CGFloat discount;

@property(nonatomic,assign)NSInteger selectedState;

@property(nonatomic,copy)NSString *discountId;

@property(nonatomic,assign)NSInteger isUsedDiscount;//是否使用优惠券 0否 1是

@property(nonatomic,copy)NSMutableArray *illArray;

@property(nonatomic,copy)NSMutableArray *lifeArray;

@property(nonatomic,copy)NSArray *illOriginalArray;//疾病

@property(nonatomic,copy)NSArray *lifeOriginalArray;//生活习惯

@end

@implementation MyOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:[UIView new]];
    _productNumber=1;
    // _price=1000;
    [self initData];
    [self createNavigation];
    [self getAllQuanData];
    [self createUI];
    [self getProductConnectData];
    // Do any additional setup after loading the view.
}
-(void)initData
{
     NSInteger isPromotion=[_model.is_promotion integerValue];
    if (isPromotion==0) {
        _price=[_model.price floatValue];
    }else{
        _price=[_model.promotion_price floatValue];
    }
    _illArray=[NSMutableArray array];
    _lifeArray=[NSMutableArray array];
}


-(void)createUI
{
    UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height-50-64)];
    scrollView.showsVerticalScrollIndicator=NO;
    [self.view addSubview:scrollView];
    scrollView.contentSize=CGSizeMake(scrollView.frame.size.width, scrollView.frame.size.height);
    _myScrollView=scrollView;
    
    //商品信息
    UILabel *productLab=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, self.view.frame.size.width-15, 35)];
    productLab.text=@"商品信息";
    productLab.textColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    productLab.font=[UIFont systemFontOfSize:16];
    [scrollView addSubview:productLab];
    
    UIView *line1=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(productLab.frame), self.view.frame.size.width, 0.5)];
    line1.backgroundColor=[UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [scrollView addSubview:line1];
    
    UIImageView *productImageView=[[UIImageView alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(line1.frame)+5, 80, 80)];
    //productImageView.image=[UIImage imageNamed:@"9.jpg"];
    NSString *imgStr=[NSString stringWithFormat:@"%@",_model.advertis_img_url];
    imgStr=[imgStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    [productImageView sd_setImageWithURL:[NSURL URLWithString:imgStr]];
    NSLog(@"商品的图片====%@",_model.advertis_img_url);
    [scrollView addSubview:productImageView];
    
    UIView *productMessageView=[[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(productImageView.frame)+5, CGRectGetMaxY(line1.frame)+5, self.view.frame.size.width-80*2-15*2-5*2, 80)];
    productMessageView.backgroundColor=[UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [scrollView addSubview:productMessageView];
    
    UILabel *productMessageLab=[[UILabel alloc]initWithFrame:CGRectMake(3, 3, productMessageView.frame.size.width-2*2, productMessageView.frame.size.height-2*2)];
    productMessageLab.text=[NSString stringWithFormat:@"     %@",_model.description1];
    productMessageLab.font=[UIFont systemFontOfSize:14];
    productMessageLab.numberOfLines=0;
    productMessageLab.textColor=[UIColor blackColor];
    [productMessageView addSubview:productMessageLab];
    if ([productMessageLab boundingRectWithSize:CGSizeMake(productMessageLab.frame.size.width, 0)].height<=productMessageLab.frame.size.height) {
        productMessageLab.frame=CGRectMake(productMessageLab.frame.origin.x, productMessageLab.frame.origin.y, productMessageLab.frame.size.width, [productMessageLab boundingRectWithSize:CGSizeMake(productMessageLab.frame.size.width, 0)].height);
    }
    
    //价格
    UILabel *moneyLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(productMessageView.frame)+5, CGRectGetMaxY(line1.frame)+5, 80, 20)];
    moneyLab.text=[NSString stringWithFormat:@"¥%.1f",_price];
    moneyLab.textColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    moneyLab.font=[UIFont systemFontOfSize:14];
    moneyLab.textAlignment=NSTextAlignmentCenter;
    [scrollView addSubview:moneyLab];
    
    UIView *line2=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(productImageView.frame)+5, self.view.frame.size.width, 15)];
    line2.backgroundColor=[UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [scrollView addSubview:line2];
    
    //购买数量
    UILabel *numberLab=[[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(line2.frame), 80, 60)];
    numberLab.text=@"购买数量";
    numberLab.font=[UIFont systemFontOfSize:16];
    numberLab.textColor=[UIColor blackColor];
    [scrollView addSubview:numberLab];
    
    //减
    UIButton *deleteBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    deleteBtn.frame=CGRectMake(self.view.frame.size.width-30-40*2-70, CGRectGetMaxY(line2.frame)+10, 40, 40);
    [deleteBtn setImage:[UIImage imageNamed:@"iconfont-jian"] forState:UIControlStateNormal];
    [deleteBtn addTarget:self action:@selector(deleteBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [scrollView addSubview:deleteBtn];
    
    UILabel *numberLab2=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(deleteBtn.frame), CGRectGetMaxY(line2.frame), 70, 60)];
    numberLab2.text=[NSString stringWithFormat:@"%ld",_productNumber];
    numberLab2.textColor=[UIColor blackColor];
    numberLab2.font=[UIFont systemFontOfSize:16];
    numberLab2.textAlignment=NSTextAlignmentCenter;
    [scrollView addSubview:numberLab2];
    _productNumberLab=numberLab2;
    
    //加
    UIButton *addBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    addBtn.frame=CGRectMake(CGRectGetMaxX(numberLab2.frame), CGRectGetMaxY(line2.frame)+10, 40, 40);
    [addBtn setImage:[UIImage imageNamed:@"iconfont-jia"] forState:UIControlStateNormal];
    [addBtn addTarget:self action:@selector(addBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [scrollView addSubview:addBtn];
    
    UIView *line3=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(numberLab.frame), self.view.frame.size.width, 15)];
    line3.backgroundColor=[UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [scrollView addSubview:line3];
    
    //优惠券
    UILabel *couponNameLab=[[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(line3.frame), 80, 60)];
    couponNameLab.text=@"优惠券";
    couponNameLab.font=[UIFont systemFontOfSize:16];
    couponNameLab.textColor=[UIColor blackColor];
    [scrollView addSubview:couponNameLab];
    
    UILabel *quanLab1=[[UILabel alloc]initWithFrame:CGRectMake(15+80+20, couponNameLab.frame.origin.y, 0, 60)];
    quanLab1.text=@"";
    quanLab1.font=[UIFont systemFontOfSize:16];
    quanLab1.textColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    [scrollView addSubview:quanLab1];
    _quanLab1=quanLab1;
    
    UILabel *dikouLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(quanLab1.frame)+10, couponNameLab.frame.origin.y, 0, 60)];
    dikouLab.text=@"";
    dikouLab.font=[UIFont systemFontOfSize:12];
    dikouLab.textColor=[UIColor grayColor];
    [scrollView addSubview:dikouLab];
    _dikouLab=dikouLab;
    
    
    
    
//    UIImageView *couponImageView=[[UIImageView alloc]initWithFrame:CGRectMake((self.view.frame.size.width-80)/2.0, 5, 80, 50)];
//    couponImageView.hidden=YES;
//    [scrollView addSubview:couponImageView];
//    _couponImageView=couponImageView;
    
    UIButton *couponBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    couponBtn.frame=CGRectMake(self.view.frame.size.width-10-25, CGRectGetMaxY(line3.frame)+15, 25, 25);
    [couponBtn setBackgroundImage:[UIImage imageNamed:@"app_right"] forState:UIControlStateNormal];
    [couponBtn addTarget:self action:@selector(couponBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [scrollView addSubview:couponBtn];
    
    UIView *line4=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(couponNameLab.frame), self.view.frame.size.width, 15)];
    line4.backgroundColor=[UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [scrollView addSubview:line4];
    
    //订单信息
    UILabel *orderLab=[[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(line4.frame), self.view.frame.size.width-15, 35)];
    orderLab.text=@"订单信息";
    orderLab.textColor=[UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222 / 255.0 alpha:1];
    orderLab.font=[UIFont systemFontOfSize:16];
    [scrollView addSubview:orderLab];
    
    UIView *line5=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(orderLab.frame), self.view.frame.size.width, 0.5)];
    line5.backgroundColor=[UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [scrollView addSubview:line5];
    
    //订单件数
    UILabel *orderNumberLab1=[[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(line5.frame), 80, 35)];
    orderNumberLab1.text=@"订单件数";
    orderNumberLab1.font=[UIFont systemFontOfSize:14];
    orderNumberLab1.textColor=[UIColor blackColor];
    [scrollView addSubview:orderNumberLab1];
    
    
    UILabel *orderNumberLab2=[[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width-60-15, orderNumberLab1.frame.origin.y, 60, 35)];
    orderNumberLab2.text=[NSString stringWithFormat:@"%ld",_productNumber];
    orderNumberLab2.textAlignment=NSTextAlignmentRight;
    orderNumberLab2.textColor=[UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222 / 255.0 alpha:1];
    orderNumberLab2.font=[UIFont systemFontOfSize:12];
    [scrollView addSubview:orderNumberLab2];
    _l1=orderNumberLab2;
    
    
    //运费
    UILabel *orderNumberLab3=[[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(orderNumberLab2.frame), 80, 35)];
    orderNumberLab3.text=@"运费";
    orderNumberLab3.font=[UIFont systemFontOfSize:14];
    orderNumberLab3.textColor=[UIColor blackColor];
    [scrollView addSubview:orderNumberLab3];
    
    UILabel *orderNumberLab4=[[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width-60-15, orderNumberLab3.frame.origin.y, 60, 35)];
    orderNumberLab4.text=@"免运费";
    orderNumberLab4.textColor=[UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222 / 255.0 alpha:1];
    orderNumberLab4.font=[UIFont systemFontOfSize:12];
    orderNumberLab4.textAlignment=NSTextAlignmentRight;
    [scrollView addSubview:orderNumberLab4];

    //支付方式
    UILabel *orderNumberLab5=[[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(orderNumberLab4.frame), 80, 35)];
    orderNumberLab5.text=@"支付方式";
    orderNumberLab5.font=[UIFont systemFontOfSize:14];
    orderNumberLab5.textColor=[UIColor blackColor];
    [scrollView addSubview:orderNumberLab5];
    
    UILabel *orderNumberLab6=[[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width-60-15, orderNumberLab5.frame.origin.y, 60, 35)];
    orderNumberLab6.text=@"支付宝";
    orderNumberLab6.textColor=[UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222 / 255.0 alpha:1];
    orderNumberLab6.font=[UIFont systemFontOfSize:12];
    orderNumberLab6.textAlignment=NSTextAlignmentRight;
    [scrollView addSubview:orderNumberLab6];
    
    //商品总金额
    UILabel *orderNumberLab7=[[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(orderNumberLab6.frame), 80, 35)];
    orderNumberLab7.text=@"商品总金额";
    orderNumberLab7.font=[UIFont systemFontOfSize:14];
    orderNumberLab7.textColor=[UIColor blackColor];
    [scrollView addSubview:orderNumberLab7];
    
    UILabel *orderNumberLab8=[[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width-160-15, orderNumberLab7.frame.origin.y, 160, 35)];
    orderNumberLab8.text=[NSString stringWithFormat:@"¥%.1f",_price];;
    orderNumberLab8.textColor=[UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222 / 255.0 alpha:1];
    orderNumberLab8.font=[UIFont systemFontOfSize:12];
    orderNumberLab8.textAlignment=NSTextAlignmentRight;
    [scrollView addSubview:orderNumberLab8];
    _l2=orderNumberLab8;

    //合计
    UILabel *orderNumberLab9=[[UILabel alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(orderNumberLab8.frame), 80, 35)];
    orderNumberLab9.text=@"合计";
    orderNumberLab9.font=[UIFont systemFontOfSize:14];
    orderNumberLab9.textColor=[UIColor blackColor];
    [scrollView addSubview:orderNumberLab9];
    _allMoney=_price;
    
    UILabel *orderNumberLab10=[[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width-15-160, orderNumberLab9.frame.origin.y, 160, 35)];
    orderNumberLab10.text=[NSString stringWithFormat:@"¥%.1f",_price];;
    orderNumberLab10.textColor=[UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222 / 255.0 alpha:1];
    orderNumberLab10.font=[UIFont systemFontOfSize:12];
    orderNumberLab10.textAlignment=NSTextAlignmentRight;
    [scrollView addSubview:orderNumberLab10];
    scrollView.contentSize=CGSizeMake(scrollView.frame.size.width, CGRectGetMaxY(orderNumberLab10.frame)+20);
    _l3=orderNumberLab10;
    
    //下一步
    UIButton *nextStepBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    nextStepBtn.frame=CGRectMake(0, self.view.frame.size.height-50, self.view.frame.size.width, 50);
    [nextStepBtn setTitle:@"下一步" forState:UIControlStateNormal];
    nextStepBtn.backgroundColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    nextStepBtn.titleLabel.font=[UIFont systemFontOfSize:16];
    [nextStepBtn addTarget:self action:@selector(nextStepBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:nextStepBtn];
    
    [self createCouponView];
//    //总金额
//    UILabel *allLab=[[UILabel alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-50, self.view.frame.size.width/2.0, 50)];
//    allLab.text=@"¥1000.0";
//    allLab.textColor=[UIColor blackColor];
//    allLab.font=[UIFont systemFontOfSize:14];
//    allLab.textAlignment=NSTextAlignmentCenter;
//    [self.view addSubview:allLab];
//    _l4=allLab;
//    
//    
//    //购买
//    UIButton *buyBtn=[UIButton buttonWithType:UIButtonTypeCustom];
//    buyBtn.frame=CGRectMake(self.view.frame.size.width/2.0, self.view.frame.size.height-50, self.view.frame.size.width/2.0, 50);
//    [buyBtn setTitle:@"立即购买" forState:UIControlStateNormal];
//    buyBtn.backgroundColor=[UIColor redColor];
//    buyBtn.titleLabel.font=[UIFont systemFontOfSize:16];
//    [buyBtn addTarget:self action:@selector(buyBtnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:buyBtn];
    
}
//创建优惠券界面
-(void)createCouponView
{
    //优惠券
    UIView *myCustomView=[[UIView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:myCustomView];
    
    UIView *myCustomBackgroundView=[[UIView alloc]initWithFrame:myCustomView.bounds];
    myCustomBackgroundView.backgroundColor=[UIColor grayColor];
    myCustomBackgroundView.alpha=0.6;
    [myCustomView addSubview:myCustomBackgroundView];
    myCustomView.hidden=YES;
    _myCustomView=myCustomView;
    
    UIButton *myCustomBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    myCustomBtn.frame=myCustomView.bounds;
    [myCustomBtn addTarget:self action:@selector(myCustomBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [myCustomView addSubview:myCustomBtn];
    
    
    UIView *myCustomSubView=[[UIView alloc]initWithFrame:CGRectMake(10, 5, self.view.frame.size.width-10*2, self.view.frame.size.height-5-70)];
    myCustomSubView.backgroundColor=[UIColor whiteColor];
    myCustomSubView.layer.borderColor=[UIColor colorWithRed:77/255.0 green:179/255.0 blue:245/255.0 alpha:1].CGColor;
    myCustomSubView.layer.borderWidth=1.0;
    myCustomSubView.layer.cornerRadius=8.0;
    [myCustomView addSubview:myCustomSubView];
    
    
    
    
    UIButton *btn11=[UIButton buttonWithType:UIButtonTypeCustom];
    btn11.frame=CGRectMake(0, 0, myCustomSubView.frame.size.width, 30);
    btn11.backgroundColor=[UIColor colorWithRed:77/255.0 green:179/255.0 blue:245/255.0 alpha:1];
    [btn11 setTitle:@"优惠券" forState:UIControlStateNormal];
    btn11.layer.borderColor=[UIColor colorWithRed:77/255.0 green:179/255.0 blue:245/255.0 alpha:1].CGColor;
    btn11.layer.borderWidth=1.0;
    btn11.layer.cornerRadius=8.0;
    btn11.titleLabel.font=[UIFont systemFontOfSize:16];
    [myCustomSubView addSubview:btn11];
    
    

    
    
    UILabel *subLab2=[[UILabel alloc]initWithFrame:CGRectMake(0, 27, myCustomSubView.frame.size.width, 40)];
    subLab2.text=[NSString stringWithFormat:@"    代金券"];
    subLab2.textColor=[UIColor blackColor];
    subLab2.font=[UIFont systemFontOfSize:16];
    subLab2.backgroundColor=[UIColor whiteColor];
    [myCustomSubView addSubview:subLab2];
    
    
    CGFloat view_w=myCustomSubView.frame.size.width;
    CGFloat view_h=(myCustomSubView.frame.size.height-(CGRectGetMaxY(subLab2.frame)+40*3+20+30+20))/2.0;
    
    UIScrollView *scrollView1=[[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(subLab2.frame), view_w, view_h)];
    scrollView1.showsVerticalScrollIndicator=NO;
    [myCustomSubView addSubview:scrollView1];
    [self createCouponSubView:scrollView1 AndDataArray:_cashCouponArray AndState:0];
    
    //折扣券
    UILabel *subLab3=[[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(subLab2.frame)+view_h, myCustomSubView.frame.size.width, 40)];
    subLab3.text=[NSString stringWithFormat:@"    折扣券"];
    subLab3.textColor=[UIColor blackColor];
    subLab3.font=[UIFont systemFontOfSize:16];
    subLab3.backgroundColor=[UIColor whiteColor];
    [myCustomSubView addSubview:subLab3];
    
    
    UIScrollView *scrollView2=[[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(subLab3.frame), view_w, view_h)];
    scrollView2.showsVerticalScrollIndicator=NO;
    [myCustomSubView addSubview:scrollView2];
    [self createCouponSubView:scrollView2 AndDataArray:_couponArray AndState:1];
    
    //兑换券
    UILabel *subLab4=[[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(subLab3.frame)+view_h, myCustomSubView.frame.size.width, 40)];
    subLab4.text=[NSString stringWithFormat:@"    兑换券"];
    subLab4.textColor=[UIColor blackColor];
    subLab4.font=[UIFont systemFontOfSize:16];
    subLab4.backgroundColor=[UIColor whiteColor];
    [myCustomSubView addSubview:subLab4];
    
    UITextField *myText3=[[UITextField alloc]initWithFrame:CGRectMake(30, CGRectGetMaxY(subLab4.frame), 150, 40)];
    myText3.layer.borderColor=[UIColor grayColor].CGColor;
    myText3.layer.borderWidth=1.0;
    myText3.layer.cornerRadius=3.0;
    myText3.placeholder=@" 请输入兑换码";
    myText3.font=[UIFont systemFontOfSize:16];
    myText3.textColor=[UIColor grayColor];
    [myCustomSubView addSubview:myText3];
    myText3.delegate=self;
    _myText3=myText3;
    myText3.returnKeyType=UIReturnKeyDone;
    myText3.keyboardType=UIKeyboardTypeNamePhonePad;
    
    
    
    //提示不能为空
    UILabel *tishiLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(myText3.frame)+10, myText3.frame.origin.y, myCustomSubView.frame.size.width-(CGRectGetMaxX(myText3.frame)+10), myText3.frame.size.height)];
    tishiLab.textColor=[UIColor colorWithRed:221/255.0 green:98/255.0 blue:11/255.0 alpha:1];
    tishiLab.font=[UIFont systemFontOfSize:13];
    [myCustomSubView addSubview:tishiLab];
    tishiLab.hidden=YES;
    _tishiLab=tishiLab;
    
    
    
    
    UIButton *getCancelBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    getCancelBtn.frame=CGRectMake((myCustomSubView.frame.size.width-120*2)/3.0, myCustomSubView.frame.size.height-20-30, 120, 30);
    getCancelBtn.backgroundColor=[UIColor colorWithRed:221/255.0 green:98/255.0 blue:11/255.0 alpha:1];
    [getCancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    getCancelBtn.titleLabel.font=[UIFont systemFontOfSize:16];
    [getCancelBtn addTarget:self action:@selector(getCancelBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [getCancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [myCustomSubView addSubview:getCancelBtn];
    
    UIButton *getBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    getBtn.frame=CGRectMake((myCustomSubView.frame.size.width-120*2)/3.0*2+120, myCustomSubView.frame.size.height-20-30, 120, 30);
    getBtn.backgroundColor=[UIColor colorWithRed:221/255.0 green:98/255.0 blue:11/255.0 alpha:1];
    [getBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    getBtn.titleLabel.font=[UIFont systemFontOfSize:16];
    [getBtn addTarget:self action:@selector(getBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [getBtn setTitle:@"兑换" forState:UIControlStateNormal];
    [myCustomSubView addSubview:getBtn];
    _myCustomView.alpha=0;
    
    _scroll1=scrollView1;
    _scroll2=scrollView2;
    _myCustomSubView=myCustomSubView;

}
//创建优惠券的子视图
-(void)createCouponSubView:(UIScrollView *)scrollView AndDataArray:(NSMutableArray *)arr AndState:(NSInteger)selectedState
{
    CGFloat btn_w=(scrollView.frame.size.width-30*2-20)/2.0-50;
    CGFloat btn_h=40;
    NSInteger hang=[self getHang:arr];
    for (int i=0;i<hang;i++) {
        for (int j=0; j<2; j++) {
            if (i*2+j<arr.count) {
                UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
                btn.frame=CGRectMake(30+(btn_w+50+20)*j, 5+(btn_h+10)*i, btn_w, btn_h);
                btn.layer.borderColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1].CGColor;
                btn.layer.borderWidth=1.0;
                [btn setTitle:arr[i*2+j][@"coupon_info"][@"title"] forState:UIControlStateNormal];
                [btn setTitleColor:[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1] forState:UIControlStateNormal];
                btn.titleLabel.font=[UIFont systemFontOfSize:16];
                btn.tag=i*2+j;
                [scrollView addSubview:btn];
                if (selectedState==0) {
                    [btn addTarget:self action:@selector(seletcedCashCouponBtnClick:) forControlEvents:UIControlEventTouchUpInside];
                }else if (selectedState==1){
                    [btn addTarget:self action:@selector(seletcedCouponBtnClick:) forControlEvents:UIControlEventTouchUpInside];
                }
                
                
                
                
                UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+3, btn.frame.origin.y+20, 50, 20)];
                lab.font=[UIFont systemFontOfSize:12];
                lab.textColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
                [scrollView addSubview:lab];
                
                NSInteger timeOut=[arr[i*2+j][@"is_timeout"] integerValue];
                if (timeOut!=0) {
                    lab.text=@"已过期";
                    lab.textColor=[UIColor grayColor];
                    btn.layer.borderColor=[UIColor grayColor].CGColor;
                    btn.layer.borderWidth=1.0;
                    [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
                    btn.userInteractionEnabled=NO;
                }else{
                    lab.textColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
                    if ([arr[i*2+j][@"timeout_time"] isKindOfClass:[NSNull class]]) {
                        lab.text=@"永久有效";
                    }else{
                        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
                        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                        NSDate *date1 = [NSDate date];
                        NSDate *date2 = [formatter dateFromString:[NSString stringWithFormat:@"%@",arr[i*2+j][@"timeout_time"]]];
                        NSTimeInterval aTimer = [date2 timeIntervalSinceDate:date1];
                        
                        int hour = (int)(aTimer/3600);
                        //int minute = (int)(aTimer - hour*3600)/60;
                        //int second = aTimer - hour*3600 - minute*60;
                        
                        int days=hour/24;
                        int hours=hour-days*24;
                        if(days<=0){
                            lab.text=[NSString stringWithFormat:@"%d小时",hours];
                        }else{
                            lab.text=[NSString stringWithFormat:@"%d天",days];
                        }
                        
                    }
                }
                

            }
            
            
        }
    }
    scrollView.contentSize=CGSizeMake(scrollView.frame.size.width, 45*hang+20);
}

//选择代金券
-(void)seletcedCashCouponBtnClick:(UIButton *)sender
{
    _selectedState=1;
    [_myText3 resignFirstResponder];
    _myCustomView.hidden=YES;
    _myCustomView.alpha=0;
    _navigationBarView.hidden=YES;
    _navigationBarView.alpha=0;
    NSLog(@"代金券====%@",_cashCouponArray[sender.tag]);
    _quanLab1.text=_cashCouponArray[sender.tag][@"coupon_info"][@"title"];
    _quanLab1.frame=CGRectMake(_quanLab1.frame.origin.x, _quanLab1.frame.origin.y, [self calculateWidthWithLable:_quanLab1], _quanLab1.frame.size.height);
    _dikouLab.text=[NSString stringWithFormat:@"最多抵扣%@元",_cashCouponArray[sender.tag][@"coupon_info"][@"value"]];
    _dikouLab.frame=CGRectMake(CGRectGetMaxX(_quanLab1.frame)+10, _dikouLab.frame.origin.y, [self calculateWidthWithLable:_dikouLab], _dikouLab.frame.size.height);
    _couponMoney=[_cashCouponArray[sender.tag][@"coupon_info"][@"value"] floatValue];
    
    _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
    _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
    _allMoney=_price*_productNumber-_couponMoney;
    _discountId=[NSString stringWithFormat:@"%@",_cashCouponArray[sender.tag][@"coupon_info"][@"id"]];
    _isUsedDiscount=1;
    
}
//选择折扣券
-(void)seletcedCouponBtnClick:(UIButton *)sender
{
    _selectedState=2;
    [_myText3 resignFirstResponder];
    _myCustomView.hidden=YES;
    _myCustomView.alpha=0;
    _navigationBarView.hidden=YES;
    _navigationBarView.alpha=0;
     NSLog(@"折扣券====%@",_couponArray[sender.tag]);
    _quanLab1.text=_couponArray[sender.tag][@"coupon_info"][@"title"];
    _quanLab1.frame=CGRectMake(_quanLab1.frame.origin.x, _quanLab1.frame.origin.y, [self calculateWidthWithLable:_quanLab1], _quanLab1.frame.size.height);
    _dikouLab.text=[NSString stringWithFormat:@"最多抵扣%@元",_couponArray[sender.tag][@"coupon_info"][@"value"]];
    _dikouLab.frame=CGRectMake(CGRectGetMaxX(_quanLab1.frame)+10, _dikouLab.frame.origin.y, [self calculateWidthWithLable:_dikouLab], _dikouLab.frame.size.height);
    _couponMoney=[_couponArray[sender.tag][@"coupon_info"][@"value"] floatValue];
    _discount=[_couponArray[sender.tag][@"coupon_info"][@"discount"] floatValue];
    
    if (_price*_productNumber*(1-_discount)>=_couponMoney) {
        _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
        _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
        _allMoney=_price*_productNumber-_couponMoney;
    }else{
        _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber*_discount];
        _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber*_discount];
        _allMoney=_price*_productNumber*_discount;
    }
    _discountId=[NSString stringWithFormat:@"%@",_couponArray[sender.tag][@"coupon_info"][@"id"]];
    
    _isUsedDiscount=1;
}





//取消兑换
-(void)getCancelBtnClick:(UIButton *)sender
{
    _myCustomView.hidden=YES;
    _myCustomView.alpha=0;
    _navigationBarView.hidden=YES;
    _navigationBarView.alpha=0;
    [_myText3 resignFirstResponder];
}
//兑换
-(void)getBtnClick:(UIButton *)sender
{
    NSLog(@"开始兑换");
    if (_myText3.text.length==0) {
        _tishiLab.hidden=NO;
        _tishiLab.text=@"兑换码不能为空";
    }else{
        [self getQuan];
    }
    [_myText3 resignFirstResponder];
}







//隐藏优惠券界面
-(void)myCustomBtnClick:(UIButton *)sender
{
    _myCustomView.hidden=YES;
    _myCustomView.alpha=0;
    _navigationBarView.hidden=YES;
    _navigationBarView.alpha=0;
    [_myText3 resignFirstResponder];
}





//下一步
-(void)nextStepBtnClick:(UIButton *)sender
{
    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
    NSString *token=[user objectForKey:@"token"];
    if (token==nil) {
        [self.view showTiShiMessage:@"请先登录"];
        return;
    }
    NSLog(@"总价格============%f",_allMoney);
    ProductNextStepViewController *vc=[[ProductNextStepViewController alloc]init];
    vc.model=_model;
    vc.productNumber=_productNumber;
    vc.allMoney=_allMoney;
    vc.discountId=_discountId;
    vc.isUsedDiscount=_isUsedDiscount;
    vc.arr1=[NSArray arrayWithArray:_illArray];
    vc.arr2=[NSArray arrayWithArray:_lifeArray];
    vc.illOriginalArray=[NSArray arrayWithArray:_illOriginalArray];
    vc.lifeOriginalArray=[NSArray arrayWithArray:_lifeOriginalArray];
    if (_illOriginalArray.count==0||_lifeOriginalArray.count==0) {
        [self.view showTiShiMessage:@"程序员GG开了个小差"];
        return;
    }
    [self.navigationController pushViewController:vc animated:YES];
}

//选择优惠券
-(void)couponBtnClick:(UIButton *)sender
{
    
    [UIView animateWithDuration:0.6 animations:^{
        _myCustomView.hidden=NO;
        _myCustomView.alpha=1;
        _navigationBarView.hidden=NO;
        _navigationBarView.alpha=1;
    }];
}

-(void)deleteBtnClick:(UIButton *)sender
{
    if (_productNumber<=1) {
        
    }else{
        _productNumber-=1;
    }
    _productNumberLab.text=[NSString stringWithFormat:@"%ld",_productNumber];
    _l1.text=[NSString stringWithFormat:@"%ld",_productNumber];
    
    if (_selectedState==1) {
        _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
        _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
        _allMoney=_price*_productNumber-_couponMoney;
    }else if (_selectedState==2){
        if (_price*_productNumber*(1-_discount)>=_couponMoney) {
            _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
            _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
            _allMoney=_price*_productNumber-_couponMoney;
        }else{
            _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber*_discount];
            _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber*_discount];
            _allMoney=_price*_productNumber*_discount;
        }
    }else{
        _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber];
        _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber];
        _allMoney=_price*_productNumber;
    }
}
-(void)addBtnClick:(UIButton *)sender
{
    _productNumber+=1;
    _productNumberLab.text=[NSString stringWithFormat:@"%ld",_productNumber];
    _l1.text=[NSString stringWithFormat:@"%ld",_productNumber];
    if (_selectedState==1) {
        _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
        _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
        _allMoney=_price*_productNumber-_couponMoney;
    }else if (_selectedState==2){
        if (_price*_productNumber*(1-_discount)>=_couponMoney) {
            _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
            _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber-_couponMoney];
            _allMoney=_price*_productNumber-_couponMoney;
        }else{
            _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber*_discount];
            _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber*_discount];
            _allMoney=_price*_productNumber*_discount;
        }
    }else{
        _l2.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber];
        _l3.text=[NSString stringWithFormat:@"¥%.1f",_price*_productNumber];
        _allMoney=_price*_productNumber;
    }

}



-(void)createNavigation
{
    self.navigationController.navigationBar.hidden=NO;
    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    //返回
    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 0, 25, 25);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    
    //标题
    UILabel *title=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
    title.text=@"订单确认-1";
    title.font=[UIFont systemFontOfSize:22];
    title.textAlignment=NSTextAlignmentCenter;
    title.textColor=[UIColor whiteColor];
    self.navigationItem.titleView=title;
    
    _navigationBarView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    _navigationBarView.hidden=YES;
    UIView *myCustomBackgroundView=[[UIView alloc]initWithFrame:_navigationBarView.bounds];
    myCustomBackgroundView.backgroundColor=[UIColor grayColor];
    myCustomBackgroundView.alpha=0.6;
    [_navigationBarView addSubview:myCustomBackgroundView];
    
    UIButton *btn11=[UIButton buttonWithType:UIButtonTypeCustom];
    btn11.frame=_navigationBarView.bounds;
    [btn11 addTarget:self action:@selector(navigationBarViewBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [_navigationBarView addSubview:btn11];
    
    
    
    
    [self.navigationController.view addSubview:_navigationBarView];
    
    
    
    
}

//隐藏navigation上的view
-(void)navigationBarViewBtnClick:(UIButton *)sender
{
    _myCustomView.hidden=YES;
    _myCustomView.alpha=0;
    _navigationBarView.hidden=YES;
    _navigationBarView.alpha=0;
}

#pragma mark 返回上一页
-(void)leftBtnClick:(UIButton *)sender
{
    self.tabBarController.tabBar.hidden=NO;
    self.navigationController.navigationBar.hidden=YES;
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//获取所有优惠券
-(void)getAllQuanData
{
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    
    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
    NSString *token=[user objectForKey:@"token"];
//    NSString *token=@"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6XC9cLzE5Mi4xNjguMTAuMTBcL2FwaVwvdXNlclwvYXV0aGVuIiwiaWF0IjoxNDYyOTQ0ODQ4LCJleHAiOjE0NjU1MzY4NDgsIm5iZiI6MTQ2Mjk0NDg0OCwianRpIjoiZTQ3YTUyYWJiODI5MjE5YjU1NGM3N2I5YzllMzBjZTMifQ.R_EW8BbONKYtsJI5h-Kpv0ctR4r1DTOrzZ-_FZnbriY";
    [manager GET:[NSString stringWithFormat:AllYouHuiQuan,token] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSArray *arr=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"所有的优惠券%@",arr);
        if (arr.count>0) {
            _cashCouponArray=[NSMutableArray array];
            _couponArray=[NSMutableArray array];
            for (NSDictionary *dic in arr) {
                NSInteger state=[dic[@"coupon_info"][@"is_discount"]integerValue];
                if (state==0) {
                    [_cashCouponArray addObject:dic];
                }else if (state==1){
                    [_couponArray addObject:dic];
                }
            }
            dispatch_async(dispatch_get_main_queue(), ^{
                for (id subView in _scroll1.subviews) {
                    [subView removeFromSuperview];
                }
                for (id subView in _scroll2.subviews) {
                    [subView removeFromSuperview];
                }
                [self createCouponSubView:_scroll1 AndDataArray:_cashCouponArray AndState:0];
                [self createCouponSubView:_scroll2 AndDataArray:_couponArray AndState:1];
            });
            
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error%@",error.localizedDescription);
    }];
}

//兑换优惠券
-(void)getQuan
{
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    
    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
    NSString *token=[user objectForKey:@"token"];
   // NSString *token=@"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6XC9cLzE5Mi4xNjguMTAuMTBcL2FwaVwvdXNlclwvYXV0aGVuIiwiaWF0IjoxNDYyOTQ0ODQ4LCJleHAiOjE0NjU1MzY4NDgsIm5iZiI6MTQ2Mjk0NDg0OCwianRpIjoiZTQ3YTUyYWJiODI5MjE5YjU1NGM3N2I5YzllMzBjZTMifQ.R_EW8BbONKYtsJI5h-Kpv0ctR4r1DTOrzZ-_FZnbriY";
    [manager POST:[NSString stringWithFormat:GetYouHuiQuan,token,_myText3.text] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"所有的优惠券%@",dic);
        if (dic[@"code"]==nil) {
            [_myCustomSubView showTiShiMessage:@"优惠码无效"];
        }else{
            [_myCustomSubView showTiShiMessage:@"兑换成功"];
            dispatch_async(dispatch_get_main_queue(), ^{
                [self getAllQuanData];
            });
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error%@",error.localizedDescription);
        [_myCustomSubView showTiShiMessage:@"兑换码无效"];
    }];

}

//根据文字计算宽度和高度
-(CGFloat)calculateWidthWithLable:(UILabel *)label
{
    CGSize size=[label.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:label.font,NSFontAttributeName, nil]];
    return size.width;
}

-(NSInteger)getHang:(NSMutableArray *)arr
{
    NSInteger hang;
    if (arr.count%2==0) {
        hang=arr.count/2;
    }else{
        hang=arr.count/2+1;
    }
    return hang;
}

-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    _tishiLab.hidden=YES;
    _tishiLab.text=nil;
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [_myText3 resignFirstResponder];
    return YES;
}

-(void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden=YES;
    self.navigationController.navigationBar.hidden=NO;
    [self.navigationController.navigationBar setTranslucent:YES];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController.navigationBar setTranslucent:NO];
}

//获取疾病史 生活偏好
-(void)getProductConnectData
{
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    NSLog(@"id====%@",_model.myID);
    [self.view isLoading:YES];
    [manager GET:[NSString stringWithFormat:GetProductDetail,_model.myID] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [self.view isLoading:NO];
        NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSArray *illArray=[NSArray arrayWithArray:dic[@"production"][@"disease_history"]];
        _illOriginalArray=[NSArray arrayWithArray:illArray];
        for (NSDictionary *dic11 in illArray) {
            [_illArray addObject:dic11[@"name"]];
        }
       NSArray *lifeArray=[NSArray arrayWithArray:dic[@"production"][@"live_prefer"]];
        _lifeOriginalArray=[NSArray arrayWithArray:lifeArray];
        for (NSDictionary *dic11 in lifeArray) {
            [_lifeArray addObject:dic11[@"name"]];
        }
        NSLog(@"得到的数据%@",dic);
        NSLog(@"数据=======%@",_illArray);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self.view isLoading:NO];
    }];

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
